package org.kardigen.lg.admin.client.training;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class ChapterEditorView extends Composite implements ChapterEditorViewDisplay {

	interface Binder extends UiBinder<Widget, ChapterEditorView> {
		Binder BINDER = GWT.create(Binder.class);
	}


	public ChapterEditorView() {
		initWidget(Binder.BINDER.createAndBindUi(this));
	}


	@UiField
	TextBox chapterName;

	@UiField
	Label label;

	private Presenter presenter;

	@UiHandler("saveAction")
	public void onSaveAction(ClickEvent event) {
		if (presenter != null) {
			presenter.onSave();
		}
	}

	@UiHandler("addWordAction")
	public void onAddWordAction(ClickEvent event) {
		if (presenter != null) {
			presenter.onAddWord();
		}
	}

	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
	}

	public HasValue<String> getChapterName() {
		return chapterName;
	}

	public HasText getLabel() {
	   return label;
   }
}
